#include "te_imports.h"
#include "te_local.h"

EngineExport exportEngine;
GameExport *exports;

/*
===========================
EngineExport::*
These are all the engine functions which get called by the
game logic DLL for various purposes.
===========================
*/

void EngineExport::Print(const char *message)
{
	Console::Print(message);
}

void EngineExport::Error(const char *message)
{
	Console::FatalError(message);
}

void EngineExport::UserError(ErrorId id, const char *msg, const char *param)
{
	og::User::Error(id, msg, param);
}

/*
===========================
VM_Create
Loads the plugins that the engine uses
===========================
*/

void VM_Create( void )
{
	Console::Print( "Loading module game\n");

	exportEngine.cmd = cmdSystemEx;
	exportEngine.cvar = cvarSystemEx;
	exportEngine.fs = og::FS;
	exportEngine.r = Renderer::GetSingleton();
	exports = (GameExport *)Plugin::Load(MODULE_NAME, &exportEngine);
	if( exports == NULL )
	{
		Console::FatalError("VM_Create() on game failed\n");
		return;
	}
}

/*
===========================
VM_Destroy
Cleans up the plugin system
===========================
*/

void VM_Destroy( void )
{
	Plugin::Unload( exports );
	exports = NULL;
}